CartesianProduct Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Computes the cartestian product of two collections: all possible pairs of items, with the first item taken from the first collection and the second item taken from the second collection. If the first collection has N items, and the second collection has M items, the cartesian product will have N * M pairs.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<Pair<TFirst, TSecond>> CartesianProduct<TFirst, TSecond>(
	IEnumerable<TFirst> first,
	IEnumerable<TSecond> second
)
Visual Basic (Declaration)
Public Shared Function CartesianProduct(Of TFirst, TSecond) ( _
	first As IEnumerable(Of TFirst), _
	second As IEnumerable(Of TSecond) _
) As IEnumerable(Of Pair(Of TFirst, TSecond))
Visual C++
public:
generic<typename TFirst, typename TSecond>
static IEnumerable<Pair<TFirst, TSecond>>^ CartesianProduct (
	IEnumerable<TFirst>^ first, 
	IEnumerable<TSecond>^ second
)

Parameters

first
IEnumerable<(Of <TFirst>)>
The first collection.
second
IEnumerable<(Of <TSecond>)>
The second collection.

Return Value

An IEnumerable<Pair<TFirst, TSecond>> that enumerates the cartesian product of the two collections.

Type Parameters

TFirst
The type of items in the first collection.
TSecond
The type of items in the second collection.

See Also